package com.gsit.expenditure.controller;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;

import com.gsit.expenditure.domain.Customer;


public class CustomerTableComponent extends BaseController   implements Initializable{
	
	 private final ObservableList<Customer> customers =   FXCollections.observableArrayList();
	
	@FXML
	private TableView<Customer> customerTable;
	
	@FXML
	private TableColumn<Customer, String> actionColumn;
	

	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		
		actionColumn.setCellValueFactory( new PropertyValueFactory<Customer, String>("firstName"));
		
	}  
	
	
	@Override
	public void onLoad() {
		customerTable.setItems(customers);
		customerTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Customer>() {

		    @Override
		    public void changed(ObservableValue<? extends Customer> observable,
		    		Customer oldValue, Customer newValue) {
		     System.out.println(">>>>>>>>>>>new value >>>>>>>>>"+ newValue.getFirstName());
		    }
		  });
	}
	
	
	
	
	
	

}
